package com.test15_异常;

/**
 * 自定义异常
 */
public class YootkDemo_04 {

    public static void main(String[] args) {
        Food.eat(10000);
    }
}

class ExplodeException extends RuntimeException {    // 选择性的异常处理
    public ExplodeException(String msg) {
        super(msg);
    }
}

class Food {
    public static void eat(int num) throws ExplodeException {
        if (num > 9999) {
            throw new ExplodeException("米饭吃太多了，肚子爆炸了！");
        } else {
            System.out.println("可以开始正常的吃饭。");
        }
    }
}
